﻿CREATE TABLE DBOrderService.DBInventory (
	ID							uniqueidentifier PRIMARY KEY,				/* Unique GUID for this inventory */
	DBOrderServiceID			uniqueidentifier NOT NULL,					/* is under this order service*/
	DBInstrumentStaticDataID	uniqueidentifier NOT NULL,					/* On instrument with such ID */
	DBLastActionID				uniqueidentifier NOT NULL,					/* Action (Corporate, Dividend ...) with such ID */
	QuantityBuy					integer NOT NULL CHECK (QuantityBuy>0),		/* Quantity Bought */
	AvgPriceBuy					float NOT NULL CHECK (AvgPriceBuy>0),		/* At this average price */
	QuantitySell				integer NOT NULL CHECK (QuantitySell>0),	/* Quantity Sold */
	AvgPriceSell				float NOT NULL CHECK (AvgPriceSell>0),		/* At this average price */
	Date 						datetime2 NOT NULL,							/* Inventory date */
	Path						varchar(255) NOT NULL,						/* Exemple : /StatArb/Euro/Strategy1/ */
	
	FOREIGN KEY (DBOrderServiceID) REFERENCES DBOrderService.DBOrderService(ID) ON DELETE CASCADE,
	
	_InsertionStamp							bigint,
	_UpdateStamp							bigint,
);